"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vue_1 = require("vue");
const element_plus_1 = require("element-plus");
const FileUpload_vue_1 = __importDefault(require("@/components/FileUpload.vue"));
const fileApi_1 = require("@/api/fileApi");
const fileUploadRef = (0, vue_1.ref)();
const emit = defineEmits(['upload-success', 'close-dialog']);
const chunks = (0, vue_1.ref)([]);
const fileName = (0, vue_1.ref)('');
const selectedTypeId = (0, vue_1.ref)(0);
const selectedChunkType = (0, vue_1.ref)(1);
const handleSuccess = (data) => {
    chunks.value = data.chunks;
    fileName.value = data.filename;
    selectedTypeId.value = data.typeId;
    selectedChunkType.value = data.chunkType;
};
const reset = () => {
    var _a;
    (_a = fileUploadRef.value) === null || _a === void 0 ? void 0 : _a.reset();
    chunks.value = [];
    fileName.value = '';
};
const __VLS_exposed = {
    reset,
};
defineExpose(__VLS_exposed);
const handleSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
    try {
        const payload = {
            filename: fileName.value,
            chunkType: selectedChunkType.value === 0
                ? '不切分'
                : selectedChunkType.value === 1
                    ? '固定长度切分'
                    : '标题增强切分',
            typeName: fileName.value.split('.').pop(),
            typeId: selectedTypeId.value,
            chunks: chunks.value,
        };
        const res = yield (0, fileApi_1.confirmUpload)(payload);
        if (res.data.code === 200) {
            element_plus_1.ElMessage.success(res.data.msg);
            // 触发父组件刷新列表和关闭弹窗
            emit('upload-success', { chunks: [], filename: '' });
            emit('close-dialog', true);
        }
        else {
            element_plus_1.ElMessage.error(res.data.msg);
        }
    }
    catch (error) {
        console.error('提交失败:', error);
        if (error instanceof Error) {
            element_plus_1.ElMessage.error('提交失败：' + error.message);
        }
        else {
            element_plus_1.ElMessage.error('提交失败');
        }
    }
});
debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
const __VLS_ctx = {};
let __VLS_components;
let __VLS_directives;
/** @type {__VLS_StyleScopedClasses['keyword-tag']} */ ;
// CSS variable injection 
// CSS variable injection end 
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(Object.assign({ class: "upload-container" }));
__VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(Object.assign({ class: "header-row" }));
__VLS_asFunctionalElement(__VLS_intrinsicElements.h2, __VLS_intrinsicElements.h2)({});
if (__VLS_ctx.chunks.length > 0) {
    const __VLS_0 = {}.ElButton;
    /** @type {[typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ]} */ ;
    // @ts-ignore
    const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0(Object.assign(Object.assign({ 'onClick': {} }, { type: "primary" }), { class: "submit-btn" })));
    const __VLS_2 = __VLS_1(Object.assign(Object.assign({ 'onClick': {} }, { type: "primary" }), { class: "submit-btn" }), ...__VLS_functionalComponentArgsRest(__VLS_1));
    let __VLS_4;
    let __VLS_5;
    let __VLS_6;
    const __VLS_7 = {
        onClick: (__VLS_ctx.handleSubmit)
    };
    __VLS_3.slots.default;
    var __VLS_3;
}
if (__VLS_ctx.fileName) {
    __VLS_asFunctionalElement(__VLS_intrinsicElements.p, __VLS_intrinsicElements.p)(Object.assign({ class: "file-name" }));
    (__VLS_ctx.fileName);
}
/** @type {[typeof FileUpload, ]} */ ;
// @ts-ignore
const __VLS_8 = __VLS_asFunctionalComponent(FileUpload_vue_1.default, new FileUpload_vue_1.default(Object.assign(Object.assign({ 'onUploadSuccess': {} }, { 'onCloseDialog': {} }), { ref: "fileUploadRef" })));
const __VLS_9 = __VLS_8(Object.assign(Object.assign({ 'onUploadSuccess': {} }, { 'onCloseDialog': {} }), { ref: "fileUploadRef" }), ...__VLS_functionalComponentArgsRest(__VLS_8));
let __VLS_11;
let __VLS_12;
let __VLS_13;
const __VLS_14 = {
    onUploadSuccess: (__VLS_ctx.handleSuccess)
};
const __VLS_15 = {
    onCloseDialog: (...[$event]) => {
        __VLS_ctx.$emit('close-dialog');
    }
};
/** @type {typeof __VLS_ctx.fileUploadRef} */ ;
var __VLS_16 = {};
var __VLS_10;
if (__VLS_ctx.chunks.length > 0) {
    __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(Object.assign({ class: "chunk-list" }));
    __VLS_asFunctionalElement(__VLS_intrinsicElements.h3, __VLS_intrinsicElements.h3)({});
    for (const [chunk] of __VLS_getVForSourceType((__VLS_ctx.chunks))) {
        const __VLS_18 = {}.ElCard;
        /** @type {[typeof __VLS_components.ElCard, typeof __VLS_components.elCard, typeof __VLS_components.ElCard, typeof __VLS_components.elCard, ]} */ ;
        // @ts-ignore
        const __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18(Object.assign({ key: (chunk.chunkId) }, { class: "chunk-item" })));
        const __VLS_20 = __VLS_19(Object.assign({ key: (chunk.chunkId) }, { class: "chunk-item" }), ...__VLS_functionalComponentArgsRest(__VLS_19));
        __VLS_21.slots.default;
        {
            const { header: __VLS_thisSlot } = __VLS_21.slots;
            __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(Object.assign({ class: "flex justify-between items-center" }));
            __VLS_asFunctionalElement(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({});
            (chunk.chunkId);
            const __VLS_22 = {}.ElTag;
            /** @type {[typeof __VLS_components.ElTag, typeof __VLS_components.elTag, typeof __VLS_components.ElTag, typeof __VLS_components.elTag, ]} */ ;
            // @ts-ignore
            const __VLS_23 = __VLS_asFunctionalComponent(__VLS_22, new __VLS_22({
                type: "info",
            }));
            const __VLS_24 = __VLS_23({
                type: "info",
            }, ...__VLS_functionalComponentArgsRest(__VLS_23));
            __VLS_25.slots.default;
            (chunk.keywords.length);
            var __VLS_25;
            const __VLS_26 = {}.ElTooltip;
            /** @type {[typeof __VLS_components.ElTooltip, typeof __VLS_components.elTooltip, typeof __VLS_components.ElTooltip, typeof __VLS_components.elTooltip, ]} */ ;
            // @ts-ignore
            const __VLS_27 = __VLS_asFunctionalComponent(__VLS_26, new __VLS_26({
                effect: "light",
                content: (chunk.keywords.join(', ')),
                placement: "top",
                popperClass: "keyword-tooltip",
            }));
            const __VLS_28 = __VLS_27({
                effect: "light",
                content: (chunk.keywords.join(', ')),
                placement: "top",
                popperClass: "keyword-tooltip",
            }, ...__VLS_functionalComponentArgsRest(__VLS_27));
            __VLS_29.slots.default;
            const __VLS_30 = {}.ElTag;
            /** @type {[typeof __VLS_components.ElTag, typeof __VLS_components.elTag, typeof __VLS_components.ElTag, typeof __VLS_components.elTag, ]} */ ;
            // @ts-ignore
            const __VLS_31 = __VLS_asFunctionalComponent(__VLS_30, new __VLS_30(Object.assign(Object.assign({ type: "info" }, { class: "keyword-tag" }), { size: "small" })));
            const __VLS_32 = __VLS_31(Object.assign(Object.assign({ type: "info" }, { class: "keyword-tag" }), { size: "small" }), ...__VLS_functionalComponentArgsRest(__VLS_31));
            __VLS_33.slots.default;
            (chunk.keywords.slice(0, 10).join(', '));
            (chunk.keywords.length > 10 ? '...' : '');
            var __VLS_33;
            var __VLS_29;
        }
        __VLS_asFunctionalElement(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(Object.assign({ class: "chunk-content" }));
        (chunk.content);
        var __VLS_21;
    }
}
/** @type {__VLS_StyleScopedClasses['upload-container']} */ ;
/** @type {__VLS_StyleScopedClasses['header-row']} */ ;
/** @type {__VLS_StyleScopedClasses['submit-btn']} */ ;
/** @type {__VLS_StyleScopedClasses['file-name']} */ ;
/** @type {__VLS_StyleScopedClasses['chunk-list']} */ ;
/** @type {__VLS_StyleScopedClasses['chunk-item']} */ ;
/** @type {__VLS_StyleScopedClasses['flex']} */ ;
/** @type {__VLS_StyleScopedClasses['justify-between']} */ ;
/** @type {__VLS_StyleScopedClasses['items-center']} */ ;
/** @type {__VLS_StyleScopedClasses['keyword-tag']} */ ;
/** @type {__VLS_StyleScopedClasses['chunk-content']} */ ;
// @ts-ignore
var __VLS_17 = __VLS_16;
var __VLS_dollars;
const __VLS_self = (await Promise.resolve().then(() => __importStar(require('vue')))).defineComponent({
    setup() {
        return {
            FileUpload: FileUpload_vue_1.default,
            fileUploadRef: fileUploadRef,
            chunks: chunks,
            fileName: fileName,
            handleSuccess: handleSuccess,
            handleSubmit: handleSubmit,
        };
    },
    emits: {},
});
exports.default = (await Promise.resolve().then(() => __importStar(require('vue')))).defineComponent({
    setup() {
        return Object.assign({}, __VLS_exposed);
    },
    emits: {},
});
; /* PartiallyEnd: #4569/main.vue */
